home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.4 Applications 1997 August / SGI IRIX 6.4 Applications 1997 August.iso / dist / dynaweb.idb / usr / lib / Insight / data / config / booktoc.dwc.z / booktoc.dwc
Encoding:
Text File  |  1997-07-30  |  6.7 KB  |  207 lines

  1.  
  2. #####################################################################
  3. #####################################################################
  4. ##                                                                 ##
  5. ##             BOOK TOC VIEW CREATION                              ##
  6. ##                                                                 ##
  7. #####################################################################
  8. #####################################################################
  9.  
  10. dwScript Generic__BookTocView {
  11.  
  12.     ## Set password for -key books.
  13.     ##
  14.     dwSetKey [dwGetParam BookPassword]
  15.  
  16.     ## Always try to go to first hit from the TOC.
  17.     dwSet State__NoAutoHit 0
  18.  
  19.     ## If the scroll position will be different from the hilite
  20.     ## position (a path would be passed in the URL as 'tl=<path>')
  21.     ## change the selection path now. 
  22.     ##
  23.     dwSet HilitePath [dwGetSelectionPath]
  24.     if {([dwGet State__TocLoc] != "") &&
  25.     ([dwGet HilitePath] != [dwGet State__TocLoc])} {
  26.       dwSetSelectionPath $State__TocLoc
  27.       dwInitTocLineGenerator [dwGet State__TocDepth] [dwGet State__TocStyle]
  28.           if {$HilitePath == ""} {
  29.          ## Hilite the root.
  30.          dwSet HilitePosition 0
  31.       } else {
  32.          ## Look for a match with the "hilite path"
  33.          dwSet HilitePosition -2
  34.       }
  35.     } else {
  36.        dwInitTocLineGenerator [dwGet State__TocDepth] [dwGet State__TocStyle]
  37.        dwSet HilitePosition [dwGetSelectedTocItemPosition]
  38.        if {$HilitePosition == ""} {dwSet HilitePosition 0}
  39.     }
  40.  
  41.     ## We hilite the line corresponding to what the content frame
  42.     ## is now showing. When this script is entered, the current
  43.     ## selection path corresponds to the content frame location.
  44.     ##
  45.     ## Highlight the root if indicated.
  46.     ##
  47.     if {$HilitePosition == 0 || $HilitePosition == -1} {
  48.        dwSet TocTitleBefore \
  49.       "<NOBR><TABLE CELLPADDING=2  border=0><TR><TD bgcolor=#C0D8FF>"
  50.        dwSet TocTitleAfter "</TABLE></NOBR>"
  51.     } else {
  52.        dwSet TocTitleBefore ""
  53.        dwSet TocTitleAfter ""
  54.     }
  55.  
  56.     ## Now compute the position in the TOC to scroll to so the selected
  57.     ## item is visible.  A simple algorithm: scroll to 10 lines before
  58.     ## the selected item.
  59.     ##
  60.     set selectedPosition [dwGetSelectedTocItemPosition]
  61.     if {$selectedPosition == ""} {set selectedPosition -1}
  62.     if {$selectedPosition < 10} {
  63.        dwSet TopScrollPoint "<A NAME=X></A>"
  64.        dwSet ScrollPosition ""
  65.     } else {
  66.        dwSet TopScrollPoint ""
  67.        dwSet ScrollPosition [expr $selectedPosition - 10]
  68.     }
  69.  
  70.     ## Some buttons want to know what we are currently displaying
  71.     dwSet ShowingTocView 1
  72.  
  73.     ## We have different templates for this page based on whether
  74.     ## or not things are being displayed in frames.
  75.     ##
  76.     if {[dwGet State__Frames] == 1} {
  77.        if {[dwGet State__UpdateOtherFrames] != 0} {
  78.       dwCall dwMakeUrlParts
  79.       dwSet JavaScript__UpdateBBarFrame \
  80.          "parent.dynaweb_bbar.location=\"[dwGet RootAbsUrlPath]/@Generic__BookButtonBarView/[dwGetSelectionPath][dwGet UrlParamString][dwGet UrlQueryString]\""
  81.        } else {
  82.           dwSet JavaScript__UpdateBBarFrame ""
  83.        }
  84.        dwProcessTemplate Frames__BookTocView
  85.     } else {
  86.        dwProcessTemplate NoFrames__BookTocView
  87.     }
  88. }
  89.  
  90. dwTemplate Frames__BookTocView {
  91. $[dwCall dwMakeUrlParts]
  92. <HTML>
  93.    <HEAD>
  94.       <TITLE>$[dwGetRootTitle]: Table of Contents</TITLE>
  95.       <BASE HREF="$[dwGet BaseUrl]@Generic__BookTocView">
  96.       <SCRIPT Language="JavaScript">
  97.       <!--
  98.      $[dwGet JavaScript__UpdateBBarFrame]
  99.       // -->
  100.       </SCRIPT>
  101.    </HEAD>
  102.       <BODY BGCOLOR=#FFFBF0 LINK=#000000 ALINK=#008000 VLINK=#800080>
  103.       $[dwGet TopScrollPoint]
  104.       $[dwGet TocTitleBefore]<H3>$[dwGetRootTitle]</H3>$[dwGet TocTitleAfter]
  105.       $[dwCall Generic__ShowSearchResult]
  106.       <HR>
  107.       $[dwCall Generic__GenerateBookTocViewBody]
  108.       <HR>
  109.    </BODY>
  110. </HTML>
  111. }
  112.  
  113. dwTemplate NoFrames__BookTocView {
  114. $[dwCall dwMakeUrlParts]
  115. $[dwSet foo [dwGet UrlParamString]]
  116. <HTML>
  117.    <HEAD>
  118.       <TITLE>$[dwGetRootTitle]: Table of Contents</TITLE>
  119.       <BASE HREF="$[dwGet BaseUrl]@Generic__BookTocView">
  120.    </HEAD>
  121.       <BODY BGCOLOR=#FFFBF0 LINK=#000000 ALINK=#008000 VLINK=#800080>
  122.       $[dwGet TopScrollPoint]
  123.       $[dwCall Generic__BookButtonBarView]
  124.       $[dwGet TocTitleBefore]<H3>Table of contents for $[dwGetRootTitle]</H3>$[dwGet TocTitleAfter]
  125.       $[dwCall Generic__ShowSearchResult]
  126.       <HR>
  127.       $[dwCall Generic__GenerateBookTocViewBody]
  128.       <HR>
  129.    </BODY>
  130. </HTML>
  131. }
  132.  
  133. dwScript Generic__GenerateBookTocViewBody {
  134.     if {[dwGetTocNumEntries] == 0} {
  135.        set ret {<p><i>[No lines generated.]</i>}
  136.     } else {
  137.        dwCall Generic__GenerateBookTocLines
  138.     }
  139. }
  140.  
  141. dwScript Generic__GenerateBookTocLines {
  142.     dwCall dwMakeUrlParts
  143.     while {[dwNewTocLine]} {
  144.  
  145.     dwSet ScrollAnchor ""
  146.     set scrollpos [dwGet ScrollPosition]
  147.     if {$scrollpos != ""} {
  148.        if {$scrollpos <= [dwGetTocItemPosition]} {
  149.           dwSet ScrollPosition ""
  150.           dwSet ScrollAnchor " NAME=X"
  151.        }
  152.     }
  153.  
  154.     dwSet TocLineIsHilited 0
  155.     if {[dwGet HilitePosition] == -2} {
  156.         if {[dwGet HilitePath] == [dwGetTocItemPath]} {
  157.            dwSet TocLineIsHilited 1
  158.         }
  159.     } elseif {[dwGet HilitePosition] == [dwGetTocItemPosition]} {
  160.        dwSet TocLineIsHilited 1
  161.     }
  162.  
  163.         set query [dwGet UrlQueryString]
  164.         regsub -all {\<}  $query {\<} query
  165.         regsub -all {\>}  $query {\>} query
  166.  
  167.     # if there are hits, goto first hit
  168.     set first_search_hit ""
  169.     set nhparam ""
  170.     if {[dwGetTocItemHitCount] > 0} {
  171.        set first_search_hit "#1"
  172.        if {[dwGetTocItemState] != "expandable"} {
  173.           set nhparam ";nh=1"
  174.        }
  175.     }
  176.  
  177.         if {[dwGet State__Frames] == 1} {
  178.            set params [dwGet UrlParamString]
  179.  
  180.            set textpath "@Generic__BookTextView/[dwGetTocItemPath]"
  181.            dwSet TocLineUrl    "$textpath$params$nhparam$query$first_search_hit"
  182.  
  183.        set tocpath "@Generic__BookTocView/[dwGet HilitePath]"
  184.        set tlparam ";tl=[dwGetTocItemPath]"
  185.            dwSet TocIconUrl    "$tocpath$tlparam$params$query#X"
  186.           
  187.        set tlparam ";tl=[dwGetTocItemExpansionPath]"
  188.            dwSet TocIconExpUrl "$tocpath$tlparam$params$query#X"
  189.  
  190.            dwSet TocLineTarget " TARGET=\"dynaweb_content\""
  191.            dwSet TocIconTarget " TARGET=\"dynaweb_toc\""
  192.     } else {
  193.            set params [dwGet UrlParamString]
  194.            set textpath "@Generic__BookTextView/[dwGetTocItemPath]$nhparam"
  195.            set tocpath  "@Generic__BookTocView/[dwGetTocItemPath]"
  196.            set exppath  "@Generic__BookTocView/[dwGetTocItemExpansionPath]"
  197.            dwSet TocLineUrl    "$textpath$params$query$first_search_hit"
  198.            dwSet TocIconUrl    "$tocpath$params$query#X"
  199.            dwSet TocIconExpUrl "$exppath$params$query#X"
  200.            dwSet TocIconTarget ""
  201.        dwSet TocLineTarget ""
  202.     }
  203.     dwCall Tables__ShowCurrentTocLine
  204.     }
  205. }
  206.  
  207.